#!/usr/bin/env python
#-*- Coding: UTF-8 -*-

import socket,sys

if len(sys.argv) <=1:
    print "Usage: ip [message]"
    sys.exit(1)

HOST=sys.argv[1]
PORT=9100

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
sock.connect((HOST,PORT))

if len(sys.argv) >= 3:
    send_string = "\x1B%%-12345X@PJL RDYMSG DISPLAY = \"%s\"\r\n\x1B%%-12345X\r\n" % sys.argv[2] #'RADIATION LEAK'
    sock.sendall(send_string)
    print "Status set"
else:
    send_string = "\x1B%%-12345X@PJL INFO STATUS\r\n\x1B%%-12345X\r\n"
    sock.send(send_string)
    data = sock.recv(64)
    print data

sock.close()
